module.exports = {
    queryObj:{
        "pageParams":{
            "page":1,
            "limit":10,
            "sidx":"",
            "order":""
        },
        "and":{
            "must": {},
            "mustNot": {},
            "like": {}, 
            "ge": {}, 
            "gt": {},
            "le": {},
            "lt": {}, 
            "between":[]
        }
        ,
        "or":{
            "must": {},
            "mustNot": {},
            "like": {}, 
            "ge": {}, 
            "gt": {},
            "le": {},
            "lt": {}, 
            "between":[] 
        }
    },
    /**
     * 
     * @param {*} page   当前页 
     * @param {*} limit  每页显示记录数
     */
    page(page,limit){
        this.queryObj.pageParams.page=page;
        this.queryObj.pageParams.limit=limit;
    },
    /**
     * @param {*} field  根据哪个字段进行排序 
     */
    sort(field){
        this.queryObj.pageParams.sidx=field;
    },
    //=====================添加或设置 并且条件============================
    /**
     *  条件类型是 等于
     */
    putAndMust(field,value){
        this.queryObj.and.must[field] = value;
    },
    /**
     *  条件类型是不等于
     */
    putAndMustNot(field,value){
        this.queryObj.and.mustNot[field] = value;
    },

    /**
     *  条件类型是 >=
     */
     putAndGe(field,value){
        this.queryObj.and.ge[field] = value;
    },

    /**
     *  条件类型是 >
     */
     putAndGt(field,value){
        this.queryObj.and.gt[field] = value;
    },

    /**
     *  条件类型是 <=
     */
     putAndLe(field,value){
        this.queryObj.and.le[field] = value;
    },

    /**
     *  条件类型是 <
     */
     putAndLt(field,value){
        this.queryObj.and.lt[field] = value;
    },

    /**
     *  条件类型是 模糊查询
     */
     putAndLike(field,value){
        this.queryObj.and.like[field] = value;
    },

    /**
     *  条件类型是 范围查询
     */
     putAndBetween(field,start,end){
        var arr=[field,start,end]; 
        this.queryObj.and.between.forEach((item,index)=>{
            if(item[0]==field){
                this.queryObj.and.between[index]=arr;
                return;
            }
        })
        this.queryObj.and.between.push(arr);
    },


    //=====================添加或设置 并且条件============================

    /**
     *  条件类型是不等于
     */
     putOrMust(field,value){
        this.queryObj.or.mustNot[field] = value;
     },

     putOrMust(field,value){
        this.queryObj.or.must[field] = value;
    },
    /**
     *  条件类型是不等于
     */
    putOrMustNot(field,value){
        this.queryObj.or.mustNot[field] = value;
    },

    /**
     *  条件类型是 >=
     */
     putOrGe(field,value){
        this.queryObj.or.ge[field] = value;
    },

    /**
     *  条件类型是 >
     */
     putOrGt(field,value){
        this.queryObj.or.gt[field] = value;
    },

    /**
     *  条件类型是 <=
     */
     putOrLe(field,value){
        this.queryObj.or.le[field] = value;
    },

    /**
     *  条件类型是 <
     */
     putOrLt(field,value){
        this.queryObj.or.lt[field] = value;
    },

    /**
     *  条件类型是 模糊查询
     */
     putOrLike(field,value){
        this.queryObj.or.like[field] = value;
    },

    /**
     *  条件类型是 范围查询
     */
     putOrBetween(field,start,end){
        var arr=[field,start,end]; 
        this.queryObj.or.between.forEach((item,index)=>{
            if(item[0]==field){
                this.queryObj.or.between[index]=arr;
                return;
            }
        })
        this.queryObj.or.between.push(arr);
    }

}